﻿@model b7.Models.Sanpham

@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_LayoutManager.cshtml";
}

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="../../Scripts/ckeditor/ckeditor.js" type="text/javascript"></script>
<script src="../../Scripts/ckfinder/ckfinder.js" type="text/javascript"></script>
<script type="text/javascript">
    function BrowseServer() {
        var finder = new CKFinder();
        finder.basePath = '../';
        finder.selectActionFunction = SetFileField;
        finder.popup();
    }
    function SetFileField(fileUrl) {
        document.getElementById('Anh').value = fileUrl;
    }
</script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Sanpham</legend>

        @Html.HiddenFor(model => model.SanphamId)

        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.NhomSanphamId)
        </div>
        <div class="editor-field">
            @Html.DropDownList("NhomSanphamId", string.Empty)
            @Html.ValidationMessageFor(model => model.NhomSanphamId)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.TheloaiId)
        </div>
        <div class="editor-field">
            @Html.DropDownList("TheloaiId", string.Empty)
            @Html.ValidationMessageFor(model => model.TheloaiId)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Anh)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Anh)
            @Html.ValidationMessageFor(model => model.Anh)
            <input type="button" value="Chọn Ảnh ..." onclick="BrowseServer();"/>
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.TomTat)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.TomTat)
            @Html.ValidationMessageFor(model => model.TomTat)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.NoiDung)
        </div>
        <div class="editor-field">
           @Html.TextAreaFor(model => model.NoiDung, new { @id = "noidung" })
            @Html.ValidationMessageFor(model => model.NoiDung)
            <script type="text/javascript">
                CKEDITOR.replace("noidung");
            </script>
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.OldPrice)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.OldPrice)
            @Html.ValidationMessageFor(model => model.OldPrice)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.SalePrice)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.SalePrice)
            @Html.ValidationMessageFor(model => model.SalePrice)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Quantity)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Quantity)
            @Html.ValidationMessageFor(model => model.Quantity)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.IsHome)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.IsHome)
            @Html.ValidationMessageFor(model => model.IsHome)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.NgayBatdau)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.NgayBatdau)
            @Html.ValidationMessageFor(model => model.NgayBatdau)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.NgayKetThuc)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.NgayKetThuc)
            @Html.ValidationMessageFor(model => model.NgayKetThuc)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.MemberId)
        </div>
        <div class="editor-field">
            @Html.DropDownList("MemberId", string.Empty)
            @Html.ValidationMessageFor(model => model.MemberId)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
